package com.itheima.health.dao;

import com.itheima.health.dto.OrderSubmitParam;
import com.itheima.health.dto.PopularPackageParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface MemberDao {
    /**
     * 数据统计
     * 会员数量数据回显对象
     */
    Integer getThisNewMember(LocalDate firstDay, LocalDate lastDay);

    /**
     * 统计会员数量
     */
    @Select("select count(*) from t_ordersubmit where order_date = #{orderDate}")
    Integer countMemberNumber(LocalDate orderDate);

    /**
     * 统计总会员数量
     */
    @Select("select count(*) from t_ordersubmit")
    Integer selectMemberNumber();

    /**
     * 本周新增会员数
     */
    @Select(" select count(*) from t_ordersubmit where order_date >= #{begin} and order_date <= #{end}")
    Integer selectByFirstTimeAndLastTime(LocalDateTime begin, LocalDateTime end);

    /**
     * 今日预约数
     */
    @Select("select count(*) from t_ordersubmit where order_date = #{reportDate}")
    Integer selectOrderByTime(LocalDate reportDate);

    /**
     * 今日到诊数
     */
    @Select("select count(*) from t_order where orderDate = #{reportDate} and orderStatus = #{status} ")
    Integer selectByStatus(LocalDate reportDate , String status);

    /**
     * 按照时间查找预约数
     */
    @Select("select count(*) from t_ordersubmit where order_date >= #{begin} and order_date <= #{end} ")
    Integer selectReservationNumber(LocalDate begin, LocalDate end);

    /**
     * 本周到诊数
     */
    @Select("select count(*) from t_order where orderDate >= #{begin} and orderDate <= #{end} and orderStatus = #{status} ")
    Integer selectReservationByTime(LocalDate begin, LocalDate end,  String status);

    /**
     * 查询订单
     * @return
     */
    @Select("select * from t_setmeal ")
    OrderSubmitParam selectOrderAll();

    /**
     * 查询今日预约数
     */
    @Select("select count(*) from t_order where orderDate = #{todayDate}")
    Integer gettodayOrderNumber(LocalDate todayDate);

    List<PopularPackageParam> gettodaySetmeal(LocalDate todayDate);
}
